<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="Pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache">
		<meta http-equiv="Expires" content="0">
		<title>FNST-在线笔试系统</title>
		<link href="./css/login.css" rel="stylesheet" type="text/css" />
	</head>

	<body>
		<div class="login_box">
			<div class="login_l_img"><img src="images/login-img.png" /></div>
			<div class="login">
				<div class="login_logo">
					<a href="#"><img src="images/login_logo.png" /></a>
				</div>
				<div class="login_name">
					<p>FNST-在线笔试系统</p>
				</div>

				<div class="layui-form" id="form">
					<div class="layui-input-inline">
						<input type="text" name="username" id="username" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline">
						<input type="password" name="password" id="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
					</div>
					<input value="登录" style="width:100%;" type="submit" id="login">
        <hr/>
       </div>
    </div>
    <div class="copyright"> by:&nbsp;FNST--版权所有©2019</div>
</div>
<div style="text-align:center;">
</div>
</body>
<script src="./layui/layui.js"></script>
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="admin/js/common.js" ></script>
<script>
	layui.config({
				base: 'admin/dist/'
			}).extend({
				notice: 'notice'
			});
			
		layui.use(['notice',  'layer'], function() {
			var notice = layui.notice; // 允许别名 toastr
				// 初始化配置，同一样式只需要配置一次，非必须初始化，有默认配置
				notice.options = {
					closeButton: true, //显示关闭按钮
					debug: false, //启用debug
					positionClass: "toast-top-right", //弹出的位置,
					showDuration: "300", //显示的时间
					hideDuration: "1000", //消失的时间
					timeOut: "2000", //停留的时间
					extendedTimeOut: "1000", //控制时间
					showEasing: "swing", //显示时的动画缓冲方式
					hideEasing: "linear", //消失时的动画缓冲方式
					iconClass: 'toast-info', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名
					onclick: null, // 点击关闭回调
				};
			var layer = layui.layer;
			$("#login").click(function() {
				if($("#username").val() == "" || $("#password").val() == "") {
					notice.warning("用户名或密码为空，不能登录！");
					return;
				}
				$.ajax({
					type: 'post',
					url: host() + "/login",
					data: {
						username: $("#username").val(),
						password: $("#password").val()
					},
					dataType: 'json',
					async: true,
//					crossDomain:true,
					success: function(msg) {
						notice.success("登陆成功");
						localStorage.setItem("token", msg.data);
						location.href = "index.html";
					},
					error: function(msg) {
						notice.error("用户名或密码不正确");
					}
				})

			})

		})
	</script>

</html>